﻿#region USING STATEMENTS
using System;
using Microsoft.Xna.Framework;
#endregion

#region CODE BODY
namespace Fusion.Objects
{
    public class AABB
    {
        //////////////////////////////////////////////////
        // Data Fields
        //////////////////////////////////////////////////
        private Rectangle BoundBox;
        private Boolean enabled;

        //////////////////////////////////////////////////
        // Member Properties
        //////////////////////////////////////////////////
        public Rectangle BoundRect
        {
            get { return BoundBox; }
        }
        public Boolean Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        //////////////////////////////////////////////////
        // Constructors
        //////////////////////////////////////////////////
        public AABB(Rectangle Bounds, Boolean IsEnabled)
        {
            BoundBox = Bounds;
        }
        public AABB(Vector2 ObjPosition, Int32 Width, Int32 Height, Boolean IsEnabled)
        {
            BoundBox = new Rectangle((Int32)ObjPosition.X, (Int32)ObjPosition.Y, Width, Height);
            Enabled = IsEnabled;
        }
        public AABB(Int32 X, Int32 Y, Int32 Width, Int32 Height, Boolean IsEnabled)
        {
            BoundBox = new Rectangle(X, Y, Width, Height);
            Enabled = IsEnabled;
        }

        //////////////////////////////////////////////////
        // Methods
        //////////////////////////////////////////////////
        public Boolean CheckCollision(BaseObject Collider)
        {
            if (!Enabled)
                return false;

            if (Collider.BoxCollider.BoundBox.Intersects(BoundBox))
                return true;

            return false;
        }
        public void MoveTo(Vector2 NewPosition)
        {
            BoundBox.X = (Int32)NewPosition.X;
            BoundBox.Y = (Int32)NewPosition.Y;
        }
        public void MoveTo(Int32 NewX, Int32 NewY)
        {
            BoundBox.X = NewX;
            BoundBox.Y = NewY;
        }
        public void ChangeSize(Int32 Width, Int32 Height)
        {
            BoundBox.Width = Width;
            BoundBox.Height = Height;
        }
    }
}
#endregion

//////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2012 Jeffery Thomas Sventora
//////////////////////////////////////////////////////////////////////////////////////////////